package com.ajavaer.framework.im.easemob.message;

import com.ajavaer.framework.common.tools.StringTools;
import com.ajavaer.framework.im.easemob.exception.EasemobErrorType;
import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class EasemobMessage {
    private String error_description;
    private String error;
    private String exception;

    public String getError_description() {
        return error_description;
    }

    public void setError_description(String error_description) {
        this.error_description = error_description;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public Boolean success() {
        return StringTools.isBlank(error) && StringTools.isBlank(error_description);
    }

    public String getException() {
        return exception;
    }

    public void setException(String exception) {
        this.exception = exception;
    }

    public String errmsg() {
        if (!success()) {
            return StringTools.format("{0}:{1}\n{2}", error, error_description, exception);
        }
        return "";
    }

    public EasemobErrorType getErrorType() {
        return EasemobErrorType.of(this.error);
    }


}
